package com.swanclouds.redfish.systems.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Lists;
import com.swanclouds.model.systems.BIOSAttribute;
import com.swanclouds.model.systems.builder.BIOSAttributeBuilder;

import java.util.List;
import java.util.Map;

/**
 * BIOS修改属性信息
 *
 * @author 张立强
 */
public class BIOSAttributeConcrete implements BIOSAttribute {

    @JsonProperty("Attributes")
    private List<Map<String,Object>> attributes;

    @Override
    public List<Map<String, Object>> getAttributes() {
        return this.attributes;
    }

    @Override
    public BIOSAttributeBuilder toBuilder() {
        return BIOSAttributeConcrete.builder();
    }

    public static BIOSAttributeBuilder builder () {
        return new BIOSAttributeConcreteBuider();
    }

    public static class BIOSAttributeConcreteBuider implements BIOSAttributeBuilder {

        BIOSAttributeConcrete m;

        BIOSAttributeConcreteBuider() {
            this(new BIOSAttributeConcrete());
        }

        BIOSAttributeConcreteBuider(BIOSAttributeConcrete m) {
            this.m = m;
        }

        /**
         * Creates and return the Model Entity M
         *
         * @return M instance
         */
        @Override
        public BIOSAttribute build() {
            return m;
        }

        /**
         * Creates a Builder using the param M as the default values
         *
         * @param in M
         * @return Builder
         */
        @Override
        public BIOSAttributeBuilder from(BIOSAttribute in) {
            m = (BIOSAttributeConcrete) in;
            return this;
        }

        @Override
        public BIOSAttributeBuilder sttributes(List<Map<String, Object>> attributes) {
            m.attributes = attributes;
            return this;
        }

        @Override
        public BIOSAttributeBuilder addAttribute(Map<String, Object> attribute) {
            if (attribute == null) {
                return this;
            }
            if (m.attributes == null) {
                m.attributes = Lists.newArrayList();
            }
            m.attributes.add(attribute);
            return this;
        }
    }
}
